#include <iostream>
#include <string>
#include <fstream>
#include "../Daemon.h"

using namespace BASE;

void daemonTest(){
	//Daemon::runDaemon("./pid.txt","/home/public/wuyaobo/Git/net/libbase/test/out.txt", "./stderr.txt");
	Daemon::runForkDaemon("./pid.txt","/home/public/wuyaobo/Git/net/libbase/test/out.txt", "./stderr.txt");
	std::ofstream ofs("./test.txt", std::ios::binary);
	std::string str = "test";
	while(true){
		std::cout << "output" << std::endl;
		ofs << str << std::endl;
		usleep(20000);
	}

}

int main(){
	std::cout << Daemon::isPidRunning("./pid.txt") << std::endl;
	std::cout << Daemon::isProcessRunning("ShowGlobalServer") << std::endl;
	daemonTest();
	return 0;
}
